<?php
include_once "test2.php";  //fungsi2...

$ta="2009/2010";
$sem="1";
include_once "query1.php";
include_once "test5.php";  //query2, insert2...
$popsize="100";	//banyaknya kemungkinan
$gen="1";		//banyaknya generasi
$matkul=$hitung1;		//banyaknya mata kuliah
$jadwal=30;		//banyaknya slot jadwal
$pm="0.25";		//persen mutasi 25%
$gens=1;


/*
	$pop_best=round($popsize/2);				//50% popsize
	$pop_rand=round(($popsize-$pop_best)/2);	//25% popsize
	$pop_mut=$popsize-($pop_best+$pop_rand);	//50% induk = 25% popsize
*/
$pop_rand=round($popsize/2);	//50% popsize
$pop_best=round(($popsize-$pop_rand)/2);				//25% popsize
$pop_mut=$popsize-($pop_best+$pop_rand);	//100% induk = 25% popsize

echo "<strong>Parameter:<br/>Tahun Ajaran: ".$ta."<br/>Semester: ".$sem."<br/>Populasi: ".$popsize."<br/>Generasi: ".$gen."<br/>Jumlah Mata Kuliah: ".$matkul."<br/>Slot Jadwal: ".$jadwal."<br/>Permutasi: ".($pm*100)."%<br/>Mata Kuliah: ".$hitung1."</strong><br /><br />";
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo "Generasi ke-";echo $gens."<br/>";
/*===========================================================================
Pembangkitan Generasi + Fitness.....
//===========================================================================*/
echo "<table border='1' style='text-align:center;'>";
echo "<tr><td></td>";
for ($a=1;$a<=$matkul;$a++)				//++
{echo "<td>".$a."</td>";}
echo "<td>fitness</td></tr>";		//++
for ($a=1;$a<=$popsize;$a++)
{
echo "<tr><td>Individu-".$a."</td>";				//
	for ($b=1;$b<=$matkul;$b++)
	{
		echo "<td>";									//
		$ggg[$b]=$kromosom[$a][$b]=mt_rand(1,$jadwal);
		echo $ggg[$b]."</td>";							//
	}
$fit_sum[$a]=quickCount($ggg);
$fit_av=$fit_av + $fit_sum[$a];
echo "<td>".$fit_sum[$a]."</td>";			//
echo "</tr>";								//
}

$fit_min=max($fit_sum);
$fit_where=inWhere($fit_sum, $fit_min);
$fit_av2=round(($fit_av/$popsize), 6);
echo "<tr><td>Best</td><td colspan='4'>".$fit_min."</td><td colspan='3'>Where</td><td>".$fit_where."</td></tr>";
echo "<tr><td>Average</td><td colspan='4'>".$fit_av2."</td></tr>";
echo "</table><br/>";
unset($fit_gbest);unset($fit_gbwhere);unset($fit_gaverage);unset($ggg);unset($fit_av);


/*===========================================================================
cek ruangan.....
//===========================================================================*/
echo "<table border='1' style='text-align:center;'>";
echo "<tr><td></td>";
for ($a=1;$a<=$matkul;$a++)				//++
{echo "<td>".$a."</td>";}
echo "<td>fitness</td></tr>";		//++
for ($a=1;$a<=$popsize;$a++)
{
echo "<tr><td>Individu-".$a."</td>";				//
	for ($b=1;$b<=$matkul;$b++)
	{
		echo "<td>";									//
		$ggg[$b]=$kromosom[$a][$b]=mt_rand(1,$jadwal);
		echo $ggg[$b]."</td>";							//
	}
$fit_sum[$a]=quickCount($ggg);
$fit_av=$fit_av + $fit_sum[$a];
echo "<td>".$fit_sum[$a]."</td>";			//
echo "</tr>";								//
}

$fit_min=max($fit_sum);
$fit_where=inWhere($fit_sum, $fit_min);
$fit_av2=round(($fit_av/$popsize), 6);
echo "<tr><td>Best</td><td colspan='4'>".$fit_min."</td><td colspan='3'>Where</td><td>".$fit_where."</td></tr>";
echo "<tr><td>Average</td><td colspan='4'>".$fit_av2."</td></tr>";
echo "</table><br/>";
unset($fit_gbest);unset($fit_gbwhere);unset($fit_gaverage);unset($ggg);unset($fit_av);


?>
